#include <string.h>
#include <iostream>
using namespace std;

class Computer{
public:
    Computer(const char * brand ,double price)
    :_brand( new char[strlen(brand) + 1]()), _price(price){
        cout << "Computer()" << endl;
        strcpy(_brand , brand);
    }
    
    void toString(){
        cout << "brand: " <<_brand << endl;cout << "price: " << _price << endl;
    }

    ~Computer(){
        if(_brand){
            delete [] _brand;
            _brand = nullptr;
        }
        cout << "析构" << endl;
    }
private:
    char * _brand;
    double _price;
};

void test0( ){
    Computer pc( " huawei" , 7000);
    pc.toString();
}

Computer pc1("apple", 18888);
void test2(){
    static Computer pc3("lenovo", 8000);
}



int main(void){
    test0();
}